from django.db import models
from django.contrib.auth.models import AbstractUser

# 第二课堂审核课程或项目
class Item(models.Model):
    item_name = models.CharField(max_length=50, null=False)
    pre_score = models.FloatField(default=0)
    contacts = models.CharField(max_length=50, default='未指定')

    def __str__(self):
        return self.item_name

# 班级
class Clas(models.Model):
    major = models.CharField(max_length=50, null=False)
    class_no = models.IntegerField(null=False)
    enroll_year = models.IntegerField(null=False)
    teacher = models.CharField(max_length=50, default='未指定')

    def __str__(self):
        return self.major,self.enroll_year,'级',self.class_no,'班'

# 用户（学生信息也包含其中）
class User(AbstractUser):
    is_student = models.BooleanField(default=0)
    student_class = models.ForeignKey(Clas, on_delete=models.CASCADE, null=True)
    student_name = models.CharField(max_length=50)
    student_id = models.BigIntegerField(null=True)

# 第二课堂分审核项
class Check(models.Model):
    student = models.ForeignKey(User, on_delete=models.CASCADE)
    item = models.ForeignKey(Item, on_delete=models.CASCADE)
    item_prize = models.CharField(max_length=50)
    score = models.FloatField()
    item_get_time = models.CharField(max_length=50)
    status = models.PositiveSmallIntegerField(null=False)
    student_has_confirm = models.BooleanField(default=0)
    create_time = models.DateTimeField()
    check_time = models.DateTimeField()

    def __str__(self):
        return self.student.student_name,'同学的',self.item.item_name,'审核'